package net.bwie.realtime.jtp.dws.log.fuction;

import org.apache.flink.api.common.functions.ReduceFunction;

public class PageViewReportReduceFunction implements ReduceFunction<PageViewBean> {

    @Override
    public PageViewBean reduce(PageViewBean tmp, PageViewBean bean) throws Exception {
        // tmp:表示增加计算中间结果,bean:表示窗口中的每一条数据
        // 1.增量计算:各个指标值相加
        tmp.setPvCount(tmp.getPvCount() + bean.getPvCount());
        tmp.setPvDuration(tmp.getPvDuration() + bean.getPvDuration());
        tmp.setUvCount(tmp.getUvCount() + bean.getUvCount());
        tmp.setSessionCount(tmp.getSessionCount() + bean.getSessionCount());
        // 2.返回结果
        return tmp;
    }
}
